package com.ninetaildemonfox.zdl.socialproject.mvp.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ninetaildemonfox.zdl.ninetaildemonfox.base.BaseFragment;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.activity.PushSettingsActivity;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter.PagerFragmentAdapter;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.fragment.ConversationListFragment;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.fragment.SystemNotificationFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author NineTailDemonFox
 * @date 2019/7/15 15:10
 * 功能描述： 消息界面
 * 联系方式：1037438704@qq.com
 */

public class NewsFragment extends BaseFragment {

    @BindView(R.id.image_left_finish)
    ImageView imageleftFinish;
    @BindView(R.id.text_center)
    TextView textCenter;
    @BindView(R.id.text_right)
    TextView textRight;

    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.article_viewpager)
    ViewPager viewPager;
    private List<Fragment> list;
    private String[] TITLE = {"聊天", "系统通知"};

    public static NewsFragment newInstance() {
        return new NewsFragment();
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_news;
    }

    @Override
    protected void onInitView(Bundle savedInstanceState) {
        textCenter.setText("消息");
        textRight.setVisibility(View.VISIBLE);
        textRight.setText("推送设置");
        list = new ArrayList<>();
        list.add(ConversationListFragment.newInstance());
        list.add(SystemNotificationFragment.newInstance());

        PagerFragmentAdapter pagerFragmentAdapter = new PagerFragmentAdapter(getChildFragmentManager(), list, TITLE);
        viewPager.setAdapter(pagerFragmentAdapter);
        viewPager.setOffscreenPageLimit(list.size());
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        tabLayout.setupWithViewPager(viewPager);
    }

    @OnClick({R.id.text_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.text_right:
                startActivity(new Intent(getContext(), PushSettingsActivity.class));
                break;
            default:
        }
    }
}